package com.yingsheng.bi.hks.service.job;

import com.yingsheng.bi.hks.basic.PUser;
import com.yingsheng.bi.hks.basic.enums.*;
import com.yingsheng.bi.hks.basic.enums.jobs.*;
import com.yingsheng.bi.hks.basic.exception.ServiceRuntimeException;
import com.yingsheng.bi.hks.basic.utils.HttpUtils;
import com.yingsheng.bi.hks.basic.utils.Subject;
import com.yingsheng.bi.hks.basic.utils.Utils;
import com.yingsheng.bi.hks.bo.JobBo;
import com.yingsheng.bi.hks.dto.Stores.StoresQryReq;
import com.yingsheng.bi.hks.dto.job.*;
import com.yingsheng.bi.hks.repository.dao.po.JobApplys;
import com.yingsheng.bi.hks.repository.dao.po.JobDetails;
import com.yingsheng.bi.hks.repository.dao.po.JobInfo;
import com.yingsheng.bi.hks.repository.dao.po.Stores;
import com.yingsheng.bi.hks.repository.dao.service.JobApplysDaoService;
import com.yingsheng.bi.hks.repository.dao.service.JobDetailDaoService;
import com.yingsheng.bi.hks.repository.dao.service.JobInfoDaoService;
import com.yingsheng.bi.hks.repository.dao.service.StoresDaoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class JobMgmtService {


    @Autowired
    private JobInfoDaoService jobInfoDaoService;

    @Autowired
    private JobDetailDaoService jobDetailDaoService;

    @Autowired
    private JobApplysDaoService jobApplysDaoService;

    /**
     * 幼儿照护新增
     *
     * @param req
     * @return
     */
    public ChildCareAddRes childCareAdd(ChildCareAddReq req) {

        PUser user = Subject.get();

        ChildCareAddRes res = new ChildCareAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setWorkPlace(req.getWorkPlace());
        jobInfo.setPosition(req.getPosition());
        jobInfo.setSalary(req.getSalary());
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumChildCare job : EnumChildCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ChildCareAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 育儿管家新增
     *
     * @param req
     * @return
     */
    public ChildButlerAddRes childButlerAdd(ChildButlerAddReq req) {

        PUser user = Subject.get();

        ChildButlerAddRes res = new ChildButlerAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setWorkPlace(req.getWorkPlace());
        jobInfo.setPosition(req.getPosition());
        jobInfo.setSalary(req.getSalary());
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumChildButler job : EnumChildButler.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ChildButlerAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }


    /**
     * 儿童陪伴师新增
     *
     * @param req
     * @return
     */
    public ChildCompanionAddRes childCompanionAdd(ChildCompanionAddReq req) {

        PUser user = Subject.get();

        ChildCompanionAddRes res = new ChildCompanionAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setWorkPlace(req.getWorkPlace());
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumChildCompanion job : EnumChildCompanion.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ChildCompanionAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                Object nameValueObject = nameField.get(req);
                if (ObjectUtils.isNotEmpty(nameValueObject)) {
                    String nameValue = (String) nameValueObject;
                    jobDetails.setFieldValue(nameValue);
                }
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 居家养老新增
     *
     * @param req
     * @return
     */
    public OlderHomeCareAddRes olderHomeCareAdd(OlderHomeCareAddReq req) {

        PUser user = Subject.get();

        OlderHomeCareAddRes res = new OlderHomeCareAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setWorkPlace(req.getWorkPlace());
        jobInfo.setSalary(req.getSalary());
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOlderHomeCare job : EnumOlderHomeCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = OlderHomeCareAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 母婴护理新增
     *
     * @param req
     * @return
     */
    public ObstetricNursingAddRes obstetricNursingAdd(ObstetricNursingAddReq req) {

        PUser user = Subject.get();

        ObstetricNursingAddRes res = new ObstetricNursingAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setWorkPlace(req.getWorkPlace());
        jobInfo.setPosition(req.getPosition());
        jobInfo.setSalary(req.getSalary());
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumObstetricNursing job : EnumObstetricNursing.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ObstetricNursingAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 家务料理新增
     *
     * @param req
     * @return
     */
    public HouseholdCareAddRes householdCareAdd(HouseholdCareAddReq req) {

        PUser user = Subject.get();

        HouseholdCareAddRes res = new HouseholdCareAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setWorkPlace(req.getWorkPlace());
        jobInfo.setPosition(req.getPosition());
        jobInfo.setSalary(req.getSalary());
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHouseholdCare job : EnumHouseholdCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = HouseholdCareAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 日常保洁
     *
     * @param req
     * @return
     */
    public DailyCleanAddRes dailyCleanAdd(DailyCleanAddReq req) {

        PUser user = Subject.get();

        DailyCleanAddRes res = new DailyCleanAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumClean job : EnumClean.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = DailyCleanAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 精细保洁
     *
     * @param req
     * @return
     */
    public FineCleanAddRes fineCleanAdd(FineCleanAddReq req) {

        PUser user = Subject.get();

        FineCleanAddRes res = new FineCleanAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumClean job : EnumClean.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = FineCleanAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 开荒保洁
     *
     * @param req
     * @return
     */
    public WastelandCleanAddRes wastelandCleanAdd(WastelandCleanAddReq req) {

        PUser user = Subject.get();

        WastelandCleanAddRes res = new WastelandCleanAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumCleanWasteland job : EnumCleanWasteland.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = WastelandCleanAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 年度套餐
     *
     * @param req
     * @return
     */
    public YearCleanRes yearCleanAdd(YearCleanReq req) {

        PUser user = Subject.get();

        YearCleanRes res = new YearCleanRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumCleanYear job : EnumCleanYear.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = YearCleanReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 儿童房整理收纳新增
     *
     * @param req
     * @return
     */
    public ChildHomeStorageAddRes sortingStorageAdd(ChildHomeStorageAddReq req) {

        PUser user = Subject.get();

        ChildHomeStorageAddRes res = new ChildHomeStorageAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOrganizeStore job : EnumOrganizeStore.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ChildHomeStorageAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 衣橱整理收纳
     *
     * @param req
     * @return
     */
    public WardrobeStorageAddRes wardrobeStorageAdd(WardrobeStorageAddReq req) {

        PUser user = Subject.get();

        WardrobeStorageAddRes res = new WardrobeStorageAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOrganizeStore job : EnumOrganizeStore.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = WardrobeStorageAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 客餐厅整理收纳
     *
     * @param req
     * @return
     */
    public CanteenStorageAddRes canteenStorageAdd(CanteenStorageAddReq req) {

        PUser user = Subject.get();

        CanteenStorageAddRes res = new CanteenStorageAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOrganizeStore job : EnumOrganizeStore.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = CanteenStorageAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 书房整理收纳
     *
     * @param req
     * @return
     */
    public StudyStorageAddRes studyStorageAdd(StudyStorageAddReq req) {

        PUser user = Subject.get();

        StudyStorageAddRes res = new StudyStorageAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOrganizeStore job : EnumOrganizeStore.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = StudyStorageAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 日常整理收纳
     *
     * @param req
     * @return
     */
    public DailyStorageAddRes dailyStorageAdd(DailyStorageAddReq req) {

        PUser user = Subject.get();

        DailyStorageAddRes res = new DailyStorageAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOrganizeStore job : EnumOrganizeStore.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = DailyStorageAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 年度陪伴式整理
     *
     * @param req
     * @return
     */
    public MultiyearStorageAddRes multiyearStorageAdd(MultiyearStorageAddReq req) {

        PUser user = Subject.get();

        MultiyearStorageAddRes res = new MultiyearStorageAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumOrganizeStore job : EnumOrganizeStore.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = MultiyearStorageAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 首席管家
     *
     * @param req
     * @return
     */
    public HeadButlerAddRes headButlerAdd(HeadButlerAddReq req) {

        PUser user = Subject.get();

        HeadButlerAddRes res = new HeadButlerAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHeadButler job : EnumHeadButler.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = HeadButlerAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 家庭事务管家
     *
     * @param req
     * @return
     */
    public DomesticHousekeeperAddRes domesticHousekeeperAdd(DomesticHousekeeperAddReq req) {

        PUser user = Subject.get();

        DomesticHousekeeperAddRes res = new DomesticHousekeeperAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumDomesticHousekeeper job : EnumDomesticHousekeeper.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = DomesticHousekeeperAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 家庭教育管家
     *
     * @param req
     * @return
     */
    public HomeEducationHousekeeperAddRes homeEducationHousekeeperAdd(HomeEducationHousekeeperAddReq req) {

        PUser user = Subject.get();

        HomeEducationHousekeeperAddRes res = new HomeEducationHousekeeperAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHomeEducationHousekeeper job : EnumHomeEducationHousekeeper.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = HomeEducationHousekeeperAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 国际教育管家
     *
     * @param req
     * @return
     */
    public InternationalEducationManagerAddRes internationalEducationManagerAdd(InternationalEducationManagerAddReq req) {

        PUser user = Subject.get();

        InternationalEducationManagerAddRes res = new InternationalEducationManagerAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumInternationalEducationManager job : EnumInternationalEducationManager.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = InternationalEducationManagerAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 宠物喂养
     *
     * @param req
     * @return
     */
    public PetFeedAddRes petFeedAdd(PetFeedAddReq req) {

        PUser user = Subject.get();

        PetFeedAddRes res = new PetFeedAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumPetFeed job : EnumPetFeed.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = PetFeedAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 宠物溜养
     *
     * @param req
     * @return
     */
    public PetWalkAddRes petWalkAdd(PetWalkAddReq req) {

        PUser user = Subject.get();

        PetWalkAddRes res = new PetWalkAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumPetWalk job : EnumPetWalk.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = PetWalkAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 家宴私厨
     *
     * @param req
     * @return
     */
    public PrivateChefAddRes privateChefAdd(PrivateChefAddReq req) {

        PUser user = Subject.get();

        PrivateChefAddRes res = new PrivateChefAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumPrivateChef job : EnumPrivateChef.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = PrivateChefAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 家电清洗
     *
     * @param req
     * @return
     */
    public ElectricalCleanAddRes electricalCleanAdd(ElectricalCleanAddReq req) {

        PUser user = Subject.get();

        ElectricalCleanAddRes res = new ElectricalCleanAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumElectricalClean job : EnumElectricalClean.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ElectricalCleanAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 管道疏通
     *
     * @param req
     * @return
     */
    public PipeDredgingAddRes pipeDredgingAdd(PipeDredgingAddReq req) {

        PUser user = Subject.get();

        PipeDredgingAddRes res = new PipeDredgingAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumpipeDredging job : EnumpipeDredging.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = PipeDredgingAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 上门开锁
     *
     * @param req
     * @return
     */
    public UnlockTheDoorAddRes unlockTheDoorAdd(UnlockTheDoorAddReq req) {

        PUser user = Subject.get();

        UnlockTheDoorAddRes res = new UnlockTheDoorAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumUnlockTheDoor job : EnumUnlockTheDoor.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = UnlockTheDoorAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 水电维修
     *
     * @param req
     * @return
     */
    public WaterElectricityRepairAddRes waterElectricityRepairAdd(WaterElectricityRepairAddReq req) {

        PUser user = Subject.get();

        WaterElectricityRepairAddRes res = new WaterElectricityRepairAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumWaterElectricityRepair job : EnumWaterElectricityRepair.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = WaterElectricityRepairAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 水电维修
     *
     * @param req
     * @return
     */
    public ElectricalRepairAddRes electricalRepairAdd(ElectricalRepairAddReq req) {

        PUser user = Subject.get();

        ElectricalRepairAddRes res = new ElectricalRepairAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumElectricalRepair job : EnumElectricalRepair.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ElectricalRepairAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 地板打蜡
     *
     * @param req
     * @return
     */
    public FloorWaxingAddRes floorWaxingAdd(FloorWaxingAddReq req) {

        PUser user = Subject.get();

        FloorWaxingAddRes res = new FloorWaxingAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumFloorWaxing job : EnumFloorWaxing.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = FloorWaxingAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 地板打蜡
     *
     * @param req
     * @return
     */
    public LeatherGoodsMaintenanceAddRes leatherGoodsMaintenanceAdd(LeatherGoodsMaintenanceAddReq req) {

        PUser user = Subject.get();

        LeatherGoodsMaintenanceAddRes res = new LeatherGoodsMaintenanceAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //幼儿照护主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumLeatherGoodsMaintenance job : EnumLeatherGoodsMaintenance.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = LeatherGoodsMaintenanceAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 政企服务
     *
     * @param req
     * @return
     */
    public BusinessAndGovernmentServicesAddRes businessAndGovernmentServicesAdd(BusinessAndGovernmentServicesAddReq req) {

        PUser user = Subject.get();

        BusinessAndGovernmentServicesAddRes res = new BusinessAndGovernmentServicesAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumBusinessAndGovernmentServices job : EnumBusinessAndGovernmentServices.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = BusinessAndGovernmentServicesAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 陪诊服务
     *
     * @param req
     * @return
     */
    public MedicalChaperonAddRes medicalChaperonAdd(MedicalChaperonAddReq req) {

        PUser user = Subject.get();

        MedicalChaperonAddRes res = new MedicalChaperonAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumMedicalChaperon job : EnumMedicalChaperon.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = MedicalChaperonAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }


    /**
     * 窗帘拆洗
     *
     * @param req
     * @return
     */
    public CurtainCleanAddRes curtainCleanAdd(CurtainCleanAddReq req) {

        PUser user = Subject.get();

        CurtainCleanAddRes res = new CurtainCleanAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHomeCare job : EnumHomeCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = CurtainCleanAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 地毯洗护
     *
     * @param req
     * @return
     */
    public CarpetWashAddRes carpetWashAdd(CarpetWashAddReq req) {

        PUser user = Subject.get();

        CarpetWashAddRes res = new CarpetWashAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHomeCare job : EnumHomeCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = CarpetWashAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 布艺沙发
     *
     * @param req
     * @return
     */
    public FabricSofaAddRes fabricSofaAdd(FabricSofaAddReq req) {

        PUser user = Subject.get();

        FabricSofaAddRes res = new FabricSofaAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHomeCare job : EnumHomeCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = FabricSofaAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 吊灯洗护
     *
     * @param req
     * @return
     */
    public ChandelierCleanAddRes chandelierCleanAdd(ChandelierCleanAddReq req) {

        PUser user = Subject.get();

        ChandelierCleanAddRes res = new ChandelierCleanAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHomeCare job : EnumHomeCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = ChandelierCleanAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    /**
     * 皮具奢护
     *
     * @param req
     * @return
     */
    public LeatherLuxuryCareAddRes leatherLuxuryCareAdd(LeatherLuxuryCareAddReq req) {

        PUser user = Subject.get();

        LeatherLuxuryCareAddRes res = new LeatherLuxuryCareAddRes();
        Date createDate = new Date();
        String jobId = Utils.genUUid();
        //工单主表
        JobInfo jobInfo = new JobInfo();
        jobInfo.setId(jobId);
        jobInfo.setUserId(user.getId());
        jobInfo.setName(req.getName());
        jobInfo.setPhone(req.getPhone());
        jobInfo.setState(EnumConst.JobFlag.JOB_FLAG_0);
        jobInfo.setCreateTime(createDate);
        EnumServiceInfo info = EnumServiceInfo.getByCode(HttpUtils.getRequestCode());
        jobInfo.setJobName(info.getName());
        jobInfo.setJobCode(HttpUtils.getRequestCode());
        jobInfo.setJobImage(info.getImageUrl());
        jobInfo.setStoresId(req.getStoresId());

        List<JobDetails> jobDetailsList = new ArrayList<>();

        for (EnumHomeCare job : EnumHomeCare.values()) {
            JobDetails jobDetails = new JobDetails();
            jobDetails.setId(Utils.genUUid());
            jobDetails.setJobId(jobId);
            jobDetails.setFieldId(job.getValue());
            jobDetails.setFieldName(job.name());
            try {
                Field nameField = LeatherLuxuryCareAddReq.class.getDeclaredField(job.name());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                String nameValue = (String) nameField.get(req);
                jobDetails.setFieldValue(nameValue);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setReturnCode("999999");
                res.setReturnMsg(e.getMessage());
                return res;
            }
            jobDetails.setCreateTime(createDate);
            jobDetailsList.add(jobDetails);
        }

        jobInfoDaoService.insert(jobInfo);
        jobDetailDaoService.insertList(jobDetailsList);
        return res;
    }

    @Autowired
    private StoresDaoService storesDaoService;

    /**
     * 工单查询
     *
     * @param req
     * @return
     */
    public JobsQryRes qry(JobsQryReq req) {
        List<JobBo> childCareBos = new ArrayList<>();
        JobsQryRes res = new JobsQryRes();

        List<JobInfo> jobInfoList = jobInfoDaoService.query(req);
        if (jobInfoList.isEmpty()) {
            return res;
        }

        List<Stores> storesList = storesDaoService.query(new StoresQryReq());

        for (int i = 0; i < jobInfoList.size(); i++) {
            JobBo jobBo = new JobBo();
            JobInfo jobInfo = jobInfoList.get(i);
            List<JobDetails> jobDetailsList = jobDetailDaoService.query(jobInfo.getId());
            jobBo.setId(jobInfo.getId());
            jobBo.setName(jobInfo.getName());
            jobBo.setPhone(jobInfo.getPhone());
            jobBo.setWorkPlace(jobInfo.getWorkPlace());
            jobBo.setPosition(jobInfo.getPosition());
            jobBo.setSalary(jobInfo.getSalary());
            jobBo.setJobName(jobInfo.getJobName());
            jobBo.setJobCode(jobInfo.getJobCode());
            jobBo.setCompanyName(jobInfo.getCompanyName());
            jobBo.setJobImage(jobInfo.getJobImage());
            jobBo.setJobBh(jobInfo.getJobBh());
            for (int j = 0; j < storesList.size(); j++) {
                Stores stores = storesList.get(j);
                if (stores.getId().equals(jobInfo.getStoresId())) {
                    jobBo.setStoresId(stores.getId());
                    jobBo.setStoresName(stores.getName());
                    jobBo.setStoresAddress(stores.getAddress());
                }
            }

            for (int j = 0; j < jobDetailsList.size(); j++) {

                JobDetails jobDetails = jobDetailsList.get(j);
                try {
                    Field nameField = JobBo.class.getDeclaredField(jobDetails.getFieldName());
                    nameField.setAccessible(true); // 取消Java的访问控制检查
                    nameField.set(jobBo, jobDetails.getFieldValue());
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                    res.setErrorCode("999999");
                    res.setErrorCode(e.getMessage());
                    return res;
                }
            }
            childCareBos.add(jobBo);
        }

        res.setChildCareBos(childCareBos);
        return res;
    }

    /**
     * 工单详情查询
     *
     * @param req
     * @return
     */
    public JobsQryByIdRes JobsQryById(JobsQryByIdReq req){
        JobBo jobBo = new JobBo();
        JobsQryByIdRes res = new JobsQryByIdRes();

        JobInfo jobInfo = jobInfoDaoService.queryById(req.getJobId());
        List<JobDetails> jobDetailsList = jobDetailDaoService.query(jobInfo.getId());
        List<Stores> storesList = storesDaoService.query(new StoresQryReq());

        jobBo.setId(jobInfo.getId());
        jobBo.setName(jobInfo.getName());
        jobBo.setPhone(jobInfo.getPhone());
        jobBo.setWorkPlace(jobInfo.getWorkPlace());
        jobBo.setPosition(jobInfo.getPosition());
        jobBo.setSalary(jobInfo.getSalary());
        jobBo.setJobName(jobInfo.getJobName());
        jobBo.setJobCode(jobInfo.getJobCode());
        jobBo.setCompanyName(jobInfo.getCompanyName());
        jobBo.setJobImage(jobInfo.getJobImage());
        jobBo.setJobBh(jobInfo.getJobBh());
        for (int j = 0; j < storesList.size(); j++) {
            Stores stores = storesList.get(j);
            if (stores.getId().equals(jobInfo.getStoresId())) {
                jobBo.setStoresId(stores.getId());
                jobBo.setStoresName(stores.getName());
                jobBo.setStoresAddress(stores.getAddress());
            }
        }

        for (int j = 0; j < jobDetailsList.size(); j++) {

            JobDetails jobDetails = jobDetailsList.get(j);
            try {
                Field nameField = JobBo.class.getDeclaredField(jobDetails.getFieldName());
                nameField.setAccessible(true); // 取消Java的访问控制检查
                nameField.set(jobBo, jobDetails.getFieldValue());
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                res.setErrorCode("999999");
                res.setErrorCode(e.getMessage());
                return res;
            }
        }
        res.setJobBo(jobBo);
        return res;
    }

    public JobsApplyRes JobsApply(JobsApplyReq req) {
        PUser user = Subject.get();
        if (!EnumConst.Role.P03.equals(user.getRoleId())) {
            throw new ServiceRuntimeException("你并非公司家政人员,如需接单请入驻欣佳源！");
        }

        List<JobInfo> jobInfos = jobInfoDaoService.queryForApply(req.getJobId(), user.getId());
        if (jobInfos.size() > 0) {
            throw new ServiceRuntimeException("您不能投递自己的工单！");
        }

        List<JobApplys> jobsQrys = jobApplysDaoService.qry(req.getJobId(), user.getId());
        if (jobsQrys.size() > 0) {
            throw new ServiceRuntimeException("您已经投递过该简历，请等待！");
        }

        JobApplys jobApplys = new JobApplys();
        jobApplys.setJobId(req.getJobId());
        jobApplys.setUserId(user.getId());
        jobApplys.setResumeId(user.getResumeId());
        jobApplys.setState(EnumConst.JobApplyFlag.JOB_APPLY_FLAG_0);
        boolean result = jobApplysDaoService.insert(jobApplys);
        return new JobsApplyRes();
    }
}
